import request from '@/utils/request';

/**
 * 获取资源列表
 * GET /promo-admin-api/resources/list
 */
export async function queryResourcesList(data: API.ResourceListParam, options?: API.baseOption) {
  return request<API.PageResourceList>('/resources/list', {
    method: 'GET',
    data,
    ...(options || {}),
  });
}

/**
 * 新增/修改资源
 * POST /promo-admin-api/resources/saveOrUpdate
 */
export async function saveOrUpdate(data: API.ResourceDetailParam, options?: API.baseOption) {
  return request<string>('/resources/saveOrUpdate', {
    method: 'POST',
    data,
    ...(options || {}),
  });
}

/**
 * 获取资详情
 * GET /promo-admin-api/resources/getDetail
 */
export async function queryResourceDetail(data: Record<'id', string>, options?: API.baseOption) {
  return request<API.ResourceDetail>('/resources/getDetail', {
    method: 'GET',
    data,
    ...(options || {}),
  });
}

/**
 * 删除资源
 * GET /promo-admin-api/resources/delete
 */
export async function deleteResource(data: Record<'id', string>, options?: API.baseOption) {
  return request<string>('/resources/delete', {
    method: 'GET',
    data,
    ...(options || {}),
  });
}

/**
 * 获取资源树
 * GET /promo-admin-api/resources/tree
 */
export async function queryResourceTree(data = {}, options?: API.baseOption) {
  return request<API.ResourceTreeItem[]>('/resources/tree', {
    method: 'GET',
    data,
    ...(options || {}),
  });
}
